package o;

import android.database.MatrixCursor;
import android.database.MatrixCursor.RowBuilder;
import com.huawei.appgallery.microsearch.bean.MicroSearchAppInfo;
import com.huawei.appgallery.microsearch.bean.MicroSearchInfoResBean;
import com.huawei.appgallery.serverreqkit.api.bean.ResponseBean;
import com.huawei.hmf.annotation.ApiDefine;
import com.huawei.hmf.annotation.Singleton;
import com.huawei.hwid.core.constants.HwAccountConstants;
import java.util.List;

@ApiDefine(uri = cmi.class)
@Singleton
public class cmk implements cmi {
    /* JADX WARNING: inconsistent code. */
    /* Code decompiled incorrectly, please refer to instructions dump. */
    public android.database.MatrixCursor ˎ(java.lang.String r8, java.lang.String[] r9, java.lang.String[] r10) {
        /*
        r7 = this;
        r1 = 1;
        if (r8 == 0) goto L_0x0009;
    L_0x0003:
        r0 = com.huawei.appgallery.microsearch.bean.MicroSearchAppInfo.ˊ(r9);
        if (r0 != 0) goto L_0x000b;
    L_0x0009:
        r0 = 0;
    L_0x000a:
        return r0;
    L_0x000b:
        r2 = "";
        r0 = o.cgp.ˏ(r10);	 Catch:{ NumberFormatException -> 0x0033 }
        if (r0 != 0) goto L_0x0021;
    L_0x0013:
        r0 = 0;
        r0 = r10[r0];	 Catch:{ NumberFormatException -> 0x0033 }
        if (r0 == 0) goto L_0x0021;
    L_0x0018:
        r0 = 0;
        r0 = r10[r0];	 Catch:{ NumberFormatException -> 0x0033 }
        r0 = java.lang.Integer.parseInt(r0);	 Catch:{ NumberFormatException -> 0x0033 }
        if (r0 >= r1) goto L_0x0022;
    L_0x0021:
        r0 = r1;
    L_0x0022:
        r3 = o.cgp.ˏ(r10);
        if (r3 != 0) goto L_0x0054;
    L_0x0028:
        r3 = r10.length;
        r4 = 2;
        if (r3 < r4) goto L_0x0054;
    L_0x002c:
        r1 = r10[r1];
    L_0x002e:
        r0 = r7.ॱ(r8, r0, r1, r9);
        goto L_0x000a;
    L_0x0033:
        r0 = move-exception;
        r3 = o.cmh.ˎ;
        r4 = "MicroSearchImpl";
        r5 = new java.lang.StringBuilder;
        r5.<init>();
        r6 = "parse selectionArgs[0] to int fail, error = ";
        r5 = r5.append(r6);
        r0 = r0.toString();
        r0 = r5.append(r0);
        r0 = r0.toString();
        r3.ˊ(r4, r0);
        r0 = r1;
        goto L_0x0022;
    L_0x0054:
        r1 = r2;
        goto L_0x002e;
        */
        throw new UnsupportedOperationException("Method not decompiled: o.cmk.ˎ(java.lang.String, java.lang.String[], java.lang.String[]):android.database.MatrixCursor");
    }

    public void ˊ(String str, int i) {
        cmr.ॱ().ˎ(str, i);
    }

    public void ˎ(String str, int i) {
        cmr.ॱ().ˊ(str, i);
    }

    public void ˊ(String str) {
        cmr.ॱ().ˊ(str);
    }

    private MatrixCursor ॱ(String str, int i, String str2, String[] strArr) {
        cvt o_cml = new cml(str2);
        o_cml.ˋ(i);
        o_cml.ˋ(str);
        o_cml.ॱ(0);
        o_cml.ˏ(1);
        ResponseBean ॱ = cfw.ॱ(o_cml);
        if (ॱ != null && ॱ.getResponseCode() == 0 && (ॱ instanceof MicroSearchInfoResBean)) {
            return ˊ((MicroSearchInfoResBean) ॱ, i, strArr);
        }
        return null;
    }

    private MatrixCursor ˊ(MicroSearchInfoResBean microSearchInfoResBean, int i, String[] strArr) {
        if (cgs.ˋ(microSearchInfoResBean.ˋ()) || microSearchInfoResBean.ˏ() < 1 || microSearchInfoResBean.ˊ() < 1) {
            cmh.ˎ.ˋ("MicroSearchImpl", "res.results_ = " + (microSearchInfoResBean.ˋ() == null ? HwAccountConstants.NULL : Integer.valueOf(microSearchInfoResBean.ˋ().size())) + ", res.totalPages_ = " + microSearchInfoResBean.ˏ() + ", res.count_ = " + microSearchInfoResBean.ˊ());
            return null;
        }
        if (i > Math.min(microSearchInfoResBean.ˋ().size(), microSearchInfoResBean.ˊ())) {
            i = microSearchInfoResBean.ˊ();
        }
        if (strArr == null) {
            strArr = MicroSearchAppInfo.ᐝ();
        }
        MatrixCursor matrixCursor = new MatrixCursor(strArr, 1);
        List ˋ = microSearchInfoResBean.ˋ();
        for (int i2 = 0; i2 < i; i2++) {
            MicroSearchAppInfo microSearchAppInfo = (MicroSearchAppInfo) ˋ.get(i2);
            RowBuilder newRow = matrixCursor.newRow();
            Object[] ॱˊ = microSearchAppInfo.ॱˊ();
            for (String ˊ : strArr) {
                newRow.add(ॱˊ[MicroSearchAppInfo.ˊ(ˊ)]);
            }
        }
        return matrixCursor;
    }
}
